<template>
  <div>
    <van-nav-bar
      class="NavBar"
      @click-left="$router.push(path)"
      @click-right="clickRight"
    >
      <template #left>
        <i class="iconfont f20 icon-xiangzuo" v-if="path"></i>
        <van-icon name="apps-o" v-else size="18px" color="white" />
      </template>
      <template #title>
        <div class="title">
          {{ title }}
        </div>
      </template>
      <template #right>
        <div class="right " v-if="right">{{ right }}</div>
        <van-icon name="search" v-else size="18px" color="white" @click="toSearch"/>
      </template>
    </van-nav-bar>
  </div>
</template>

<script>
export default {
  name: 'NavBar',
  props: ['title', 'right', 'path'],
  methods: {
    clickRight () {
      this.$emit('rightClick')
    },
    // 去搜索页
    toSearch () {
      this.$router.push('/home/search')
    }
  }
}
</script>
<style lang="less" scoped>
.NavBar {
  //   padding: 0 15px;
  background-color: #429efa;
  .f20 {
    font-size: 20px;
  }
  color: #fff;
  /* ::v-deep .van-nav-bar__left,
  ::v-deep .van-nav-bar__right {
    padding-left: 0;
    padding-right: 0;
  } */
  .pr15 {
    padding-right: 15px;
  }
  .title {
    font-size: 18px;
    font-family: PingFangSC, PingFangSC-Semibold;
    font-weight: 400;
    text-align: left;
    color: #fff;
    line-height: 25px;
    letter-spacing: 0px;
  }
  .right {
    font-size: 16px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: right;
    color: #fff;
    line-height: 20px;
    letter-spacing: 0px;
  }
}
</style>
